<?php

use yii\helpers\Html;
use yii\grid\GridView;
use yii\widgets\Pjax;
use yii\grid\CheckboxColumn;
use services\models\minisite\MActivityShowFeelReply;
use services\models\cache\MemberInfo;

/* @var $this yii\web\View */
/* @var $searchModel backend\models\MActivityShowFeelReplySearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = MActivityShowFeelReply::$CHANNEL[Yii::$app->controller->channel] . '管理';
$this->params['breadcrumbs'][] = $this->title;
?>
    <div class="box box-success">
        <div class="box-body">
            <div class="mactivity-show-feel-reply-index">
                <?php $this->head(); ?>

                <?php Pjax::begin(); ?>
                <?= GridView::widget([
                    'dataProvider' => $dataProvider,
                    //'filterModel' => $searchModel,
                    'columns' => [
                        ['class' => CheckboxColumn::className(),

                        ],
                        'id',
                        'uid',
                        [
                            'label' => '用户名',
                            'value' => function ($data) {
                                return MemberInfo::get($data->uid)->username;
                            },
                        ],
                        'c_content',
                        [
                            'label' => '提交时间',
                            'attribute' => 'db_time',
                        ],
                        [
                            'class' => 'yii\grid\ActionColumn',
                            'template' => '{delete}',
                            'header' => '操作'

                        ],

                    ],
                ]); ?>
                <p>
                    <?= Html::button('批量删除', ['class' => 'btn btn-success', 'id' => 'deletes']) ?>
                </p>

                <?php Pjax::end(); ?></div>

        </div>
    </div>
<?php $this->beginBlock('js'); ?>
    <script>
        $(function () {
            $("#deletes").click(function () {
                var ids = new Array();
                $('[name="selection[]"]').each(function (i, item) {
                    if ($(item).is(':checked')) {
                        ids.push($(item).parentsUntil('tbody').last().attr('data-key'))

                    }

                })
                if (ids.length == 0) {
                    alert('请选择要删除的数据后进行操作!')
                    return
                }
                if (confirm('您确定要执行该操作吗？')) {
                    window.location.href = '<?=Yii::$app->urlManager->createUrl([Yii::$app->controller->id . '/delete','id'=>''])?>' + ids.join(',');
                    return false;
                }


            });
        });
    </script>
<?php $this->endBlock(); ?>